package com.byit.controller;

import com.byit.config.MinioConfig;
import com.byit.domain.AppNews;
import com.byit.domain.vo.AboutUsVo;
import com.byit.domain.vo.ContactUsVo;
import com.byit.msg.MessageResult;
import com.byit.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;

@Controller
@RequestMapping("/app/h5")
public class AppH5Controller {

    @Autowired
    private ConfigService configService;

    @Autowired
    private MinioConfig minioConfig;

    @GetMapping("/noData.html")
    public Object selectAppNewsById() {

        ModelAndView view = new ModelAndView("building");
        String str = minioConfig.getSearchMinio() + "/zhjy/h5/building.png";
        view.addObject("building", str);

        return view;
    }

    /**
     * 联系我们h5页面
     *
     * @return
     */
    @GetMapping("/aboutUs")
    public Object getAboutUs() {

        AboutUsVo aboutUsVo = configService.getAboutUs();

        if (aboutUsVo == null) {
            return MessageResult.error();
        }
        ModelAndView view = new ModelAndView("aboutUs");
        view.addObject("videoPath", minioConfig.getSearchMinio() + aboutUsVo.getVideoPath());
        view.addObject("content", aboutUsVo.getContent());
        view.addObject("timestamp", new Date());

        return view;
    }
}